package com.yunwushanhe.controller;



import com.yunwushanhe.bean.ret.ResponseResult;
import com.yunwushanhe.bean.vo.CommentVO;
import com.yunwushanhe.bean.vo.PageVO;
import com.yunwushanhe.constant.Constant;
import com.yunwushanhe.entity.Comment;
import com.yunwushanhe.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评论表(Comment)表控制层
 *
 * @author 抬头看看天
 * @since 2023-08-12 17:11:57
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论",description = "评论相关接口")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/commentList")
    public ResponseResult<PageVO<List<CommentVO>>> commentList(Long articleId, Integer pageNum, Integer pageSize){
        System.out.println("===================="+pageNum+"======="+pageSize+"===========================");
        return commentService.commentList(Constant.ARTICLE_COMMENT,articleId, pageNum, pageSize);
    }

    @PostMapping()
    public ResponseResult<Object> addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

    @GetMapping("/linkCommentList")
    @ApiOperation(value = "友链评论列表",notes = "获取一页友链评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页号"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小")
    }
    )
    public ResponseResult<PageVO<List<CommentVO>>> linkCommentList(Integer pageNum, Integer pageSize){
        return commentService.commentList(Constant.LINK_COMMENT,null, pageNum, pageSize);
    }

}

